<template>
  <div class="content">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm" size="mini">
      <el-form-item label="餐费名称" prop="name">
        <el-input class="title" v-model="ruleForm.name" placeholder="请输入餐费名称" clearable></el-input>
      </el-form-item>

      <p>请选择餐费标准：</p>

      <el-radio v-model="radio" label="1">每天相同</el-radio>

      <div class="everyDaySame">
        <div>
          <p>早餐</p>
          <p>1元</p>
        </div>
        <div>
          <p>午餐</p>
          <p>1元</p>
        </div>
        <div>
          <p>晚餐</p>
          <p>1元</p>
        </div>
      </div>


      <el-radio v-model="radio" label="2">每天不同</el-radio>

      <template>
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="dateNum"
            label="星期"
            width="180">
          </el-table-column>
          <el-table-column
            prop="name"
            label="早餐（元）">
            <template slot-scope="scope">
              <el-input @blur="aa" v-model="fade['input-'+scope.$index+scope.column.id]" placeholder="请输入费用" size="mini"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="address"
            label="午餐（元）">
            <template slot-scope="scope">
              <el-input v-model="fade['input-'+scope.$index+scope.column.id]" placeholder="请输入费用" size="mini"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="address"
            label="晚餐（元）">
            <template slot-scope="scope">
              <el-input v-model="fade['input-'+scope.$index+scope.column.id]" placeholder="请输入费用" size="mini"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </template>


      <el-form-item style="margin-top: 20px">
        <el-button type="primary" @click="submitForm('ruleForm')">{{$t("action.save")}}</el-button>
        <el-button @click="resetForm('ruleForm')">{{$t("action.reset")}}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
    export default {
        name: "edit",
        data() {
            return {
                fade:{},
                radio:'',//选择每天相同和每天不同
                ruleForm: {
                    name: '',//时间名称
                },
                rules: {
                    name: [
                        {required: true, message: '请输入时间名称', trigger: 'blur'},
                        {min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur'}
                    ],

                },
                tableData: [{
                    dateNum: '星期一',
                    id:0,
                },{
                    dateNum: '星期二',
                    id:1,
                },{
                    dateNum: '星期三',
                    id:2,
                },{
                    dateNum: '星期四',
                    id:3,
                },{
                    dateNum: '星期五',
                    id:4,
                }]
            };
        },
        methods: {
            aa(){
              console.log(this.fade)
            },
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }

    }
</script>

<style scoped lang="scss">
  .everyDaySame{
    display: flex;
    border: 1px solid #EBEEF5;
    margin: 15px 0;
    p{
      width: 50px;
      padding-left: 20px;
    }
  }
  .content{
    padding: 0 5%;
  }
  .title{
    width: 50%;
  }
  .el-table{
    margin-top: 15px;
  }
</style>
